
from sql.sql_conn import *
from hguang.hg_conn import *

if __name__ == '__main__':
    sq = Mysql_data()
    n = 0
    username = 'zxc123zxcab'
    password = 'Zxc123123'
    nn = 'bb'  # 和fb匹配就改 fb,和bb匹配就改 bb
    con = Conn(username, password)
    ver, uid, session = con.conn_login()
    while True:
        # try:

        t1 = time.time()
        if n == 10 or n == 0:
            # con = Conn('zxc123zxcab', 'Zxc123123')
            # ver, uid, session = con.conn_login()
            try:
                da = Date_conn(ver, uid, session)
                alll = da.date_all()
                da.hg_duiwu(alll, nn)
                print('////////')
            except:
                print("******")
                con = Conn(username, password)
                ver, uid, session = con.conn_login()
            n = 0
        n += 1
        try:
            if nn == 'bb':
                nnn = "FB_game_id,FB_region_id"
            else:
                nnn = "BB_game_id,BB_region_id"
            fb_bb_id = select_gun(nnn, 'bisai_fb_bb_duiwu')
            id_all = sq.run_sql(fb_bb_id)
            bb_id = [(i[0], i[1]) for i in id_all][::-1]  # []
            if len(bb_id) != 0:
                dat = da.hg_run(bb_id)
                # print(bb_id)
                # da.hg_handle_one(dat)
                print(time.time() - t1)
                time.sleep(2)

            else:
                print("等等")
                time.sleep(120)
        except Exception as e:
            print(e)
            time.sleep(20)

        # alll = da.hg_one()
        # da.hg_handle_one(alll)

        # time.sleep(2)
        # print(time.time() - t1)
        # except Exception as e:
        #     print(e)
        #     con = Conn('asd123asdaa', 'Zxc123123')
        #     ver, uid, session = con.conn_login()